package org.dromara.oce.controller.admin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.dto.TypeDto;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.oce.domain.bo.OceEverydayCostHoursBo;
import org.dromara.oce.domain.dto.*;
import org.dromara.oce.domain.req.OceAdvertiserEverydayCostQueryModel;
import org.dromara.oce.domain.req.OceEverydayCostHoursQueryModel;
import org.dromara.oce.domain.vo.OceEverydayCostHoursVo;
import org.dromara.oce.service.OceEverydayCostHoursService;
import org.dromara.oce.utils.DateTimeUtil;
import org.dromara.oce.utils.PlatformParamTransUtil;
import org.dromara.oce.utils.TimeUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 广告主消耗记录
 *
 * @author Lion Li
 * @date 2024-12-24
 * @module 管理平台接口
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oce/everydayCostHours")
public class OceEverydayCostHoursController extends BaseController {

    private final OceEverydayCostHoursService oceEverydayCostHoursService;

    /**
     * 查询广告主消耗记录列表
     */
    @SaCheckPermission("oce:everydayCostHours:list")
    @GetMapping("/list")
    public TableDataInfo<OceEverydayCostHoursVo> list(OceEverydayCostHoursBo bo, PageQuery pageQuery) {
        LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
        String nowStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00"));
        long hourNow = TimeUtils.getHoursTimestamp(nowStr);
        bo.setThatdayHoursTimestamp(hourNow);
        pageQuery.setOrderByColumn("thatdayHoursTimestamp");
        pageQuery.setIsAsc("desc");
        return oceEverydayCostHoursService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取广告主消耗记录详细信息
     *
     * @param advertiserCostId 主键
     */
    @SaCheckPermission("oce:everydayCostHours:query")
    @GetMapping("/{advertiserCostId}")
    public R<OceEverydayCostHoursVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long advertiserCostId) {
        return R.ok(oceEverydayCostHoursService.queryById(advertiserCostId));
    }

    /**
     * 新增广告主消耗记录
     */
    @SaCheckPermission("oce:everydayCostHours:add")
    @Log(title = "广告主消耗记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody OceEverydayCostHoursBo bo) {
        return toAjax(oceEverydayCostHoursService.insertByBo(bo));
    }

    /**
     * 修改广告主消耗记录
     */
    @SaCheckPermission("oce:everydayCostHours:edit")
    @Log(title = "广告主消耗记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody OceEverydayCostHoursBo bo) {
        return toAjax(oceEverydayCostHoursService.updateByBo(bo));
    }

    /**
     * 删除广告主消耗记录
     *
     * @param advertiserCostIds 主键串
     */
    @SaCheckPermission("oce:everydayCostHours:remove")
    @Log(title = "广告主消耗记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{advertiserCostIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] advertiserCostIds) {
        return toAjax(oceEverydayCostHoursService.deleteWithValidByIds(List.of(advertiserCostIds), true));
    }

    /**
     * 总时速列表
     * @param query
     * @return
     */
    @SaCheckPermission("oce:everydayCostHours:listHoursTotal")
    @GetMapping("/getOceEverydayHoursTotalCost")
    public TableDataInfo<GetOceEverydayHoursTotalCostDTO> getOceEverydayHoursTotalCost(OceAdvertiserEverydayCostQueryModel query){
        TableDataInfo<GetOceEverydayHoursTotalCostDTO> tableDataInfo = new TableDataInfo<>();
        OceEverydayCostHoursBo bo = new OceEverydayCostHoursBo();
        BeanUtil.copyProperties(query, bo);
        Long timestamps = DateTimeUtil.getTimestampSecond(query.getStartDate());
        if (!ObjectUtils.isEmpty(query.getStartDate())) {
            bo.setStartDate(query.getStartDate());
            query.setStartTimestamp(timestamps);
        }
        if (!ObjectUtils.isEmpty(query.getEndDate())) {
            bo.setEndDate(query.getEndDate());
            query.setEndTimestamp(DateTimeUtil.getTimestampSecond(query.getEndDate()));
        }
        Long deptId = LoginHelper.getDeptId();
        if (!LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin()) {
            bo.setDeptId(deptId);
        }
        Long deptIdCache = PlatformParamTransUtil.getDynamicDept();
        if (deptIdCache > 0L) {
            bo.setDeptId(deptIdCache);
        }
        LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
        String nowDateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        long nowDate = TimeUtils.getTimestampSecond(nowDateStr);
        if(timestamps >= nowDate){
            String nowStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00"));
            long hourNow = TimeUtils.getHoursTimestamp(nowStr);
            bo.setThatdayHoursTimestamp(hourNow);
        }
        List<TypeDto> sum = new ArrayList<>();
        GetOceEverydayCostCensusDataDTO censusDataDto = oceEverydayCostHoursService.getHourSum(bo);
        if(Objects.nonNull(censusDataDto)) {
            // 总消耗
            BigDecimal cost = censusDataDto.getCost();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(cost+"");
                typeDto.setDesc("总消耗");
                sum.add(typeDto);
            }
            // 当日总支付笔数
            Integer thatdayPaidTotalNum = censusDataDto.getThatdayPaidTotalNum();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayPaidTotalNum+"");
                typeDto.setDesc("总支付笔数");
                sum.add(typeDto);
            }
            // 当日总收入
            BigDecimal thatdayTotalAmount = censusDataDto.getThatdayRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayTotalAmount+"");
                typeDto.setDesc("订单充值");
                sum.add(typeDto);
            }
            // 当日分成金额
            BigDecimal thatdayDividendAmount = censusDataDto.getThatdayRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayDividendAmount+"");
                typeDto.setDesc("订单分成");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterTotalAmount = censusDataDto.getIaaRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterTotalAmount+"");
                typeDto.setDesc("广告收入");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterDividendAmount = censusDataDto.getIaaRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterDividendAmount+"");
                typeDto.setDesc("广告分成");
                sum.add(typeDto);
            }
            // 当日利润金额=当日分成金额-当日消耗
            BigDecimal thatdayProfitAmount = censusDataDto.getThatdayRegisterProfitAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayProfitAmount+"");
                typeDto.setDesc("总利润");
                sum.add(typeDto);
            }
            // 回本率
            BigDecimal extRecoveryRate = censusDataDto.getExtRegisterRecoveryRate();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(extRecoveryRate+"%");
                typeDto.setDesc("回本率");
                sum.add(typeDto);
            }
        }
        tableDataInfo.setSum(sum);
        List<GetOceEverydayHoursTotalCostDTO> list = oceEverydayCostHoursService.getOceEverydayHoursTotalCost(bo);
        tableDataInfo.setRows(list);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("success");
        return tableDataInfo;
    }

    /**
     * 小时时速列表
     * @param query
     * @return
     */
    @SaCheckPermission("oce:everydayCostHours:listHours")
    @GetMapping("/getHoursCostPage")
    public TableDataInfo<OceEverydayCostHoursDTO> getHoursCostPage(OceEverydayCostHoursQueryModel query){
        TableDataInfo<OceEverydayCostHoursDTO> tableDataInfo = new TableDataInfo<>();
        List<OceEverydayCostHoursDTO> dtos = new ArrayList<>();
        OceEverydayCostHoursBo bo = new OceEverydayCostHoursBo();
        bo.setReferralLinkId(query.getReferralLinkId());
        bo.setThatdayTimestamp(query.getThatdayTimestamp());
        Long deptId = LoginHelper.getDeptId();
        if(!LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin()){
            bo.setDeptId(deptId);
        }
        Long deptIdCache = PlatformParamTransUtil.getDynamicDept();
        if (deptIdCache > 0L) {
            bo.setDeptId(deptIdCache);
        }
        Long timestamps = query.getThatdayTimestamp();
        LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
        String nowDateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        long nowDate = TimeUtils.getTimestampSecond(nowDateStr);
        if(timestamps >= nowDate){
            String nowStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00"));
            long hourNow = TimeUtils.getHoursTimestamp(nowStr);
            bo.setThatdayHoursTimestamp(hourNow);
        }
        PageQuery pageQuery = new PageQuery(24,1);
        pageQuery.setOrderByColumn("thatdayHoursTimestamp");
        pageQuery.setIsAsc("desc");
        List<TypeDto> sum = new ArrayList<>();
        GetOceEverydayCostCensusDataDTO censusDataDto = oceEverydayCostHoursService.getHourSum(bo);
        if(Objects.nonNull(censusDataDto)) {
            // 总消耗
            BigDecimal cost = censusDataDto.getCost();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(cost+"");
                typeDto.setDesc("总消耗");
                sum.add(typeDto);
            }
            // 当日总支付笔数
            Integer thatdayPaidTotalNum = censusDataDto.getThatdayPaidTotalNum();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayPaidTotalNum+"");
                typeDto.setDesc("总支付笔数");
                sum.add(typeDto);
            }
            // 当日总收入
            BigDecimal thatdayTotalAmount = censusDataDto.getThatdayRegisterTotalAmount();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayTotalAmount+"");
                typeDto.setDesc("订单充值");
                sum.add(typeDto);
            }
            // 当日分成金额
            BigDecimal thatdayDividendAmount = censusDataDto.getThatdayRegisterDividendAmount();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayDividendAmount+"");
                typeDto.setDesc("订单分成");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterTotalAmount = censusDataDto.getIaaRegisterTotalAmount();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterTotalAmount+"");
                typeDto.setDesc("广告收入");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterDividendAmount = censusDataDto.getIaaRegisterDividendAmount();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterDividendAmount+"");
                typeDto.setDesc("广告分成");
                sum.add(typeDto);
            }
            // 当日利润金额=当日分成金额-当日消耗
            BigDecimal thatdayProfitAmount = censusDataDto.getThatdayRegisterProfitAmount();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayProfitAmount+"");
                typeDto.setDesc("总利润");
                sum.add(typeDto);
            }
            // 回本率
            BigDecimal extRecoveryRate = censusDataDto.getExtRegisterRecoveryRate();
            if(bo.getReferralLinkId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(extRecoveryRate+"%");
                typeDto.setDesc("回本率");
                sum.add(typeDto);
            }
        }
        tableDataInfo.setSum(sum);
        TableDataInfo<OceEverydayCostHoursVo> dataInfo = oceEverydayCostHoursService.queryPageList(bo, pageQuery);
        List<OceEverydayCostHoursVo> list = dataInfo.getRows();
        if(CollectionUtils.isNotEmpty(list)){
            for (OceEverydayCostHoursVo vo : list) {
                OceEverydayCostHoursDTO dto = new OceEverydayCostHoursDTO();
                BeanUtil.copyProperties(vo,dto);
                dto.setThatdayProfitAmount(vo.getThatdayRegisterProfitAmount());
                dtos.add(dto);
            }
        }
        tableDataInfo.setCode(dataInfo.getCode());
        tableDataInfo.setMsg(dataInfo.getMsg());
        tableDataInfo.setRows(dtos);
        tableDataInfo.setTotal(dataInfo.getTotal());
        return tableDataInfo;
    }

    /**
     * 总消耗时段充值趋势图 - 汇总
     * @param query
     * @return
     */
    @SaCheckPermission("oce:everydayCostHours:listCost")
    @GetMapping("/getTotalHoursBlockPayAmount")
    public TableDataInfo<GetOceEverydayHoursTotalCostDTO> getTotalHoursBlockPayAmount(OceAdvertiserEverydayCostQueryModel query){
        TableDataInfo<GetOceEverydayHoursTotalCostDTO> tableDataInfo = new TableDataInfo<>();
        OceEverydayCostHoursBo bo = new OceEverydayCostHoursBo();
        BeanUtil.copyProperties(query, bo);
        Long timestamps = DateTimeUtil.getTimestampSecond(query.getStartDate());
        if (!ObjectUtils.isEmpty(query.getStartDate())) {
            bo.setStartDate(query.getStartDate());
            query.setStartTimestamp(timestamps);
        }
        if (!ObjectUtils.isEmpty(query.getEndDate())) {
            bo.setEndDate(query.getEndDate());
            query.setEndTimestamp(DateTimeUtil.getTimestampSecond(query.getEndDate()));
        }
        Long deptId = LoginHelper.getDeptId();
        if (!LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin()) {
            bo.setDeptId(deptId);
        }
        Long deptIdCache = PlatformParamTransUtil.getDynamicDept();
        if (deptIdCache > 0L) {
            bo.setDeptId(deptIdCache);
        }
        LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
        String nowDateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        long nowDate = TimeUtils.getTimestampSecond(nowDateStr);
        if(timestamps >= nowDate){
            String nowStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00"));
            long hourNow = TimeUtils.getHoursTimestamp(nowStr);
            bo.setThatdayHoursTimestamp(hourNow);
        }
        List<TypeDto> sum = new ArrayList<>();
        GetOceEverydayCostCensusDataDTO censusDataDto = oceEverydayCostHoursService.getHourSum(bo);
        if(Objects.nonNull(censusDataDto)) {
            // 总消耗
            BigDecimal cost = censusDataDto.getCost();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(cost+"");
                typeDto.setDesc("总消耗");
                sum.add(typeDto);
            }
            // 当日总支付笔数
            Integer thatdayPaidTotalNum = censusDataDto.getThatdayPaidTotalNum();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayPaidTotalNum+"");
                typeDto.setDesc("总支付笔数");
                sum.add(typeDto);
            }
            // 当日总收入
            BigDecimal thatdayTotalAmount = censusDataDto.getThatdayRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayTotalAmount+"");
                typeDto.setDesc("订单充值");
                sum.add(typeDto);
            }
            // 当日分成金额
            BigDecimal thatdayDividendAmount = censusDataDto.getThatdayRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayDividendAmount+"");
                typeDto.setDesc("订单分成");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterTotalAmount = censusDataDto.getIaaRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterTotalAmount+"");
                typeDto.setDesc("广告收入");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterDividendAmount = censusDataDto.getIaaRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterDividendAmount+"");
                typeDto.setDesc("广告分成");
                sum.add(typeDto);
            }
            // 当日利润金额=当日分成金额-当日消耗
            BigDecimal thatdayProfitAmount = censusDataDto.getThatdayRegisterProfitAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayProfitAmount+"");
                typeDto.setDesc("总利润");
                sum.add(typeDto);
            }
            // 回本率
            BigDecimal extRecoveryRate = censusDataDto.getExtRegisterRecoveryRate();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(extRecoveryRate+"%");
                typeDto.setDesc("回本率");
                sum.add(typeDto);
            }
        }
        tableDataInfo.setSum(sum);
        List<GetOceEverydayHoursTotalCostDTO> list = oceEverydayCostHoursService.getOceEverydayHoursTotalCost(bo);
        tableDataInfo.setRows(list);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("success");
        return tableDataInfo;
    }

    /**
     * 时段充值趋势图  -- 列表中数据
     * @param query
     * @return
     */
    @SaCheckPermission("oce:everydayCostHours:listOrder")
    @GetMapping("/getHoursBlockPayAmount")
    public TableDataInfo<GetHoursBlockPayAmountDTO> getHoursBlockPayAmount(OceEverydayCostHoursQueryModel query){
        TableDataInfo<GetHoursBlockPayAmountDTO> tableDataInfo = new TableDataInfo<>();
        OceEverydayCostHoursBo bo = new OceEverydayCostHoursBo();
        bo.setReferralLinkId(query.getReferralLinkId());
        bo.setThatdayTimestamp(query.getThatdayTimestamp());
        Long deptId = LoginHelper.getDeptId();
        if (!LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin()) {
            bo.setDeptId(deptId);
        }
        Long deptIdCache = PlatformParamTransUtil.getDynamicDept();
        if (deptIdCache > 0L) {
            bo.setDeptId(deptIdCache);
        }
        Long timestamps = query.getThatdayTimestamp();
        LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
        String nowDateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        long nowDate = TimeUtils.getTimestampSecond(nowDateStr);
        if(timestamps >= nowDate){
            String nowStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00"));
            long hourNow = TimeUtils.getHoursTimestamp(nowStr);
            bo.setThatdayHoursTimestamp(hourNow);
        }
        List<TypeDto> sum = new ArrayList<>();
        GetOceEverydayCostCensusDataDTO censusDataDto = oceEverydayCostHoursService.getHourSum(bo);
        if(Objects.nonNull(censusDataDto)) {
            // 总消耗
            BigDecimal cost = censusDataDto.getCost();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(cost+"");
                typeDto.setDesc("总消耗");
                sum.add(typeDto);
            }
            // 当日总支付笔数
            Integer thatdayPaidTotalNum = censusDataDto.getThatdayPaidTotalNum();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayPaidTotalNum+"");
                typeDto.setDesc("总支付笔数");
                sum.add(typeDto);
            }
            // 当日总收入
            BigDecimal thatdayTotalAmount = censusDataDto.getThatdayRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayTotalAmount+"");
                typeDto.setDesc("订单充值");
                sum.add(typeDto);
            }
            // 当日分成金额
            BigDecimal thatdayDividendAmount = censusDataDto.getThatdayRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayDividendAmount+"");
                typeDto.setDesc("订单分成");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterTotalAmount = censusDataDto.getIaaRegisterTotalAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterTotalAmount+"");
                typeDto.setDesc("广告收入");
                sum.add(typeDto);
            }
            BigDecimal iaaRegisterDividendAmount = censusDataDto.getIaaRegisterDividendAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(iaaRegisterDividendAmount+"");
                typeDto.setDesc("广告分成");
                sum.add(typeDto);
            }
            // 当日利润金额=当日分成金额-当日消耗
            BigDecimal thatdayProfitAmount = censusDataDto.getThatdayRegisterProfitAmount();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(thatdayProfitAmount+"");
                typeDto.setDesc("总利润");
                sum.add(typeDto);
            }
            // 回本率
            BigDecimal extRecoveryRate = censusDataDto.getExtRegisterRecoveryRate();
            if(bo.getDeptId() != null) {
                TypeDto typeDto = new TypeDto();
                typeDto.setType(extRecoveryRate+"%");
                typeDto.setDesc("回本率");
                sum.add(typeDto);
            }
        }
        tableDataInfo.setSum(sum);
        List<GetHoursBlockPayAmountDTO> dtos = oceEverydayCostHoursService.getHoursBlockPayAmount(bo);
        tableDataInfo.setRows(dtos);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("success");
        return tableDataInfo;
    }

}
